package com.zy.bootdemo.controller;

import com.zy.bootdemo.service.CustomerService;
import com.zy.bootdemo.util.JSONUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Resource
    CustomerService customerService;
    @GetMapping("selectAll")
    public String selectAll(){
        return JSONUtil.getJson(customerService.selectAll());
    }
    @GetMapping("selectOne")
    public String selectOne(Integer id){

        return JSONUtil.getJson(customerService.selectOne(id));
    }
    @PostMapping("/insertOne")
    public boolean insertOne(String cName,String cNum,String cPhone,Integer rNum){
        return customerService.insertOne(cName,cNum,cPhone,rNum);
    }
    @PostMapping("/delOne")
    public boolean delOne(Integer id){
        return customerService.delOne(id);
    }

}
